package com.mybatis.lo.utils;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.io.SAXReader;

import java.io.InputStream;
import java.io.Reader;

/**
 * 文档工具
 * @author zhangbh
 * 2023-06-13 08:20
 **/
public class DocumentUtils {

    public static Document createDocument(InputStream inputStream) {
        SAXReader reader = new SAXReader();
        try {
            return reader.read(inputStream);
        } catch (DocumentException e) {
            System.out.println("解析配置文件异常");
            throw new RuntimeException(e);
        }
    }

    public static Document createDocument(Reader rd) {
        SAXReader reader = new SAXReader();
        try {
            return reader.read(rd);
        } catch (DocumentException e) {
            System.out.println("解析配置文件异常");
            throw new RuntimeException(e);
        }
    }
}
